package com.hongminzheng.openapi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hongminzheng.openapi.mapper.ApplicationMapper;
import com.hongminzheng.openapi.mapper.CustomerMapper;
import com.hongminzheng.openapi.pojo.Application;
import com.hongminzheng.openapi.pojo.Customer;
import com.hongminzheng.openapi.service.ApplicationService;
import lombok.extern.log4j.Log4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author hmz
 * @version v1.0
 * @data 2020/09/29
 **/
@Service
public class ApplicationServiceImpl implements ApplicationService {


    @Autowired
    ApplicationMapper applicationMapper;

    /**
     * 增加
     * @param application
     * @return
     */
    @Override
    public int insert(Application application) {
        return applicationMapper.insert(application);
    }

    /**
     * 更新
     * @param application
     * @return
     */
    @Override
    public int updateByPrimaryKey(Application application) {
        return applicationMapper.updateByPrimaryKey(application);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return applicationMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(Application application) {
        return applicationMapper.insertSelective(application);
    }

    @Override
    public Application selectByPrimaryKey(Integer id) {
        return applicationMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(Application application) {
        return applicationMapper.updateByPrimaryKeySelective(application);
    }

    /**
     * 分页查询
     * @param pageNum
     * @param pageSize
     * @param application
     * @return
     */
    @Override
    public PageInfo<Application> findPage(Integer pageNum, Integer pageSize, Application application) {
        PageHelper.startPage(pageNum, pageSize);
        List<Application> applications = applicationMapper.findByCropName(application);
        PageInfo<Application> pageInfo = new PageInfo<>(applications);
        return pageInfo;
    }

}
